package jp.co.toshiba.ffsa.service.cstp;

import jp.co.toshiba.ffsa.entity.Information;

import org.seasar.extension.jdbc.JdbcManager;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.SingletonS2Container;
import org.seasar.framework.container.factory.SingletonS2ContainerFactory;

/**
 * お知らせ詳細ページビジネスロジック
 * @author npc
 */
public class Cstp102Service {

    /** お知らせエンティティ*/
    private Information information;

    /** お知らせIDで情報取得
     * @param informationId
     * @return Information
     * @throws Exception
     */
    public Information getInformationBySubject(String informationId) throws Exception {
         // S2Container初期化
        SingletonS2ContainerFactory.init();
        // S2ContainerからJdbcManagerを取得
        JdbcManager jdbcManager = SingletonS2Container.getComponent(JdbcManager.class);
       try{
            // 検索条件
            SimpleWhere swh = new SimpleWhere().eq("informationId", informationId);

            information = jdbcManager.from(Information.class)
                                     .where(swh)
                                     .getSingleResult();

        }catch(Exception e){
            throw e;
        }
       return information;
    }
}